home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
System-Boost
/
Workbench
/
Archive
/
PPCxDMS
/
source.lha
/
src
/
u_rle.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-02-28
|
799b
|
48 lines
/*
* xDMS v1.1 - Portable DMS archive unpacker - Public Domain
* Written by Andre R. de la Rocha <adlroc@usa.net>
*
* Run Length Encoding decompression function used in most
* modes after decompression by other algorithm
*
*/
#include <string.h>
#include "cdata.h"
#include "u_rle.h"
USHORT Unpack_RLE(UCHAR *in, UCHAR *out, USHORT origsize){
USHORT n;
UCHAR a,b, *outend;
outend = out+origsize;
while (out<outend){
a = *in++;
if (a != 0x90) {
*out++ = a;
} else {
b = *in++;
if (b == 0) {
*out++ = a;
} else {
a = *in++;
if (b == 0xff) {
n = *in++;
n = (USHORT)((n<<8) + *in++);
} else {
n = b;
}
if (out+n > outend) return 1;
memset(out,a,(size_t) n);
out += n;
}
}
}
return 0;
}